package com.slz3.business.module.drawManagement.draGoods.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class DraGoodsFactory {

    /**
     * 初始化基础属性值
     */
    public static DraGoods initBaseFields(DraGoods draGoods) {
        if (draGoods.getUuid() == null) {
            draGoods.setUuid(UUIDUtils.generateUUID());
            draGoods.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(draGoods.getSerAudit())) {
                draGoods.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(draGoods.getSerUsing())) {
                draGoods.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            draGoods.setLastModifyTime(LocalDateTime.now());
        }
        return draGoods;
    }

    /**
     * 初始化基础属性值
     */
    public static DraGoods initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static DraGoods newTemStyle() {
        return new DraGoods();
    }

}
